import { IPSChartGridXAxis } from './ipschart-grid-xaxis';
import { IPSChartGridYAxis } from './ipschart-grid-yaxis';
import { IPSDEChart } from './ipsdechart';
import { IPSDEChartGrid } from './ipsdechart-grid';
import { PSDEChartCoordinateSystemControlImplBase2 } from './psdechart-coordinate-system-control-impl-base2';

export class PSDEChartGridImpl extends PSDEChartCoordinateSystemControlImplBase2 implements IPSDEChartGrid {
  protected pschartgridxaxis0: IPSChartGridXAxis | null = null;

  getPSChartGridXAxis0(): IPSChartGridXAxis | null {
    if (this.pschartgridxaxis0 != null) return this.pschartgridxaxis0;
    const value = this.M.getPSChartGridXAxis0;
    if (value == null) {
      return null;
    }
    const ipsdechart = this.getParentPSModelObject('control.chart.IPSDEChart') as IPSDEChart;
    if (ipsdechart != null) {
      this.pschartgridxaxis0 = ipsdechart.findPSChartXAxis(value) as IPSChartGridXAxis;
    }
    return this.pschartgridxaxis0;
  }

  get psChartGridXAxis0(): IPSChartGridXAxis | null {
    return this.getPSChartGridXAxis0();
  }

  getPSChartGridXAxis0Must(): IPSChartGridXAxis {
    const value = this.getPSChartGridXAxis0();
    if (value == null) {
      throw new Error('未指定绘图表格X轴[0]');
    }
    return value;
  }

  protected pschartgridxaxis1: IPSChartGridXAxis | null = null;

  getPSChartGridXAxis1(): IPSChartGridXAxis | null {
    if (this.pschartgridxaxis1 != null) return this.pschartgridxaxis1;
    const value = this.M.getPSChartGridXAxis1;
    if (value == null) {
      return null;
    }
    const ipsdechart = this.getParentPSModelObject('control.chart.IPSDEChart') as IPSDEChart;
    if (ipsdechart != null) {
      this.pschartgridxaxis1 = ipsdechart.findPSChartXAxis(value) as IPSChartGridXAxis;
    }
    return this.pschartgridxaxis1;
  }

  get psChartGridXAxis1(): IPSChartGridXAxis | null {
    return this.getPSChartGridXAxis1();
  }

  getPSChartGridXAxis1Must(): IPSChartGridXAxis {
    const value = this.getPSChartGridXAxis1();
    if (value == null) {
      throw new Error('未指定绘图表格X轴[1]');
    }
    return value;
  }

  protected pschartgridyaxis0: IPSChartGridYAxis | null = null;

  getPSChartGridYAxis0(): IPSChartGridYAxis | null {
    if (this.pschartgridyaxis0 != null) return this.pschartgridyaxis0;
    const value = this.M.getPSChartGridYAxis0;
    if (value == null) {
      return null;
    }
    const ipsdechart = this.getParentPSModelObject('control.chart.IPSDEChart') as IPSDEChart;
    if (ipsdechart != null) {
      this.pschartgridyaxis0 = ipsdechart.findPSChartYAxis(value) as IPSChartGridYAxis;
    }
    return this.pschartgridyaxis0;
  }

  get psChartGridYAxis0(): IPSChartGridYAxis | null {
    return this.getPSChartGridYAxis0();
  }

  getPSChartGridYAxis0Must(): IPSChartGridYAxis {
    const value = this.getPSChartGridYAxis0();
    if (value == null) {
      throw new Error('未指定绘图表格Y轴[0]');
    }
    return value;
  }

  protected pschartgridyaxis1: IPSChartGridYAxis | null = null;

  getPSChartGridYAxis1(): IPSChartGridYAxis | null {
    if (this.pschartgridyaxis1 != null) return this.pschartgridyaxis1;
    const value = this.M.getPSChartGridYAxis1;
    if (value == null) {
      return null;
    }
    const ipsdechart = this.getParentPSModelObject('control.chart.IPSDEChart') as IPSDEChart;
    if (ipsdechart != null) {
      this.pschartgridyaxis1 = ipsdechart.findPSChartYAxis(value) as IPSChartGridYAxis;
    }
    return this.pschartgridyaxis1;
  }

  get psChartGridYAxis1(): IPSChartGridYAxis | null {
    return this.getPSChartGridYAxis1();
  }

  getPSChartGridYAxis1Must(): IPSChartGridYAxis {
    const value = this.getPSChartGridYAxis1();
    if (value == null) {
      throw new Error('未指定绘图表格Y轴[1]');
    }
    return value;
  }

  get cls(): string {
    return 'PSDEChartGridImpl';
  }

  instanceof(cls: string): boolean {
    if (
      cls == 'IPSModelObject' ||
      cls == 'IPSObject' ||
      cls == 'control.chart.IPSChartCoordinateSystemControl' ||
      cls == 'control.chart.IPSChartGrid' ||
      cls == 'control.chart.IPSChartObject' ||
      cls == 'control.chart.IPSDEChartGrid' ||
      cls == 'control.chart.IPSDEChartObject'
    )
      return true;
    return super.instanceof(cls);
  }
}
